def plusOne(digits):
    n = len(digits) - 1
    car = (digits[n] + 1) // 10
    digits[n] = (digits[n] + 1) % 10
    if car == 0:
        return digits
    n = n - 1
    while n >= 0:
        temp = digits[n]
        digits[n] = (temp + car) % 10
        car = (temp + car) // 10
        if car == 0:
            return digits
        n = n - 1
    if car == 1:  # 数组最开始需要补上一个1
        digits.insert(0, 1)
    return digits

if __name__ == '__main__':
    plusOne([9,9])